package com.zyong.design.pattern.command.case2;

/**
 * @program: zyong-design-pattern
 * @ClassName: Client
 * @author: zyong
 * @create: 2024-03-27 23:37
 */
public class Client {
    public static void main(String[] args) {
        /**
         * 电灯:electric light
         * 电视:television
         * 冰箱:refrigerator
         * 洗衣机:washing machine
         * 晾衣架:clothes hanger
         */
        ElectricLightReceiver electricLightReceiver = new ElectricLightReceiver();
        ElectricLightOnCommand electricLightOnCommand = new ElectricLightOnCommand(electricLightReceiver);
        ElectricLightOffCommand electricLightOffCommand = new ElectricLightOffCommand(electricLightReceiver);

        TelevisionReceiver televisionReceiver = new TelevisionReceiver();
        TelevisionOnCommand televisionOnCommand = new TelevisionOnCommand(televisionReceiver);
        TelevisionOffCommand televisionOffCommand = new TelevisionOffCommand(televisionReceiver);

        RefrigeratorReceiver refrigeratorReceiver = new RefrigeratorReceiver();
        RefrigeratorOnCommand refrigeratorOnCommand = new RefrigeratorOnCommand(refrigeratorReceiver);
        RefrigeratorOffCommand refrigeratorOffCommand = new RefrigeratorOffCommand(refrigeratorReceiver);

        WashingMachineReceiver washingMachineReceiver = new WashingMachineReceiver();
        WashingMachineOnCommand washingMachineOnCommand = new WashingMachineOnCommand(washingMachineReceiver);
        WashingMachineOffCommand washingMachineOffCommand = new WashingMachineOffCommand(washingMachineReceiver);

        ClothesHangerReceiver clothesHangerReceiver = new ClothesHangerReceiver();
        ClothesHangerOnCommand clothesHangerOnCommand = new ClothesHangerOnCommand(clothesHangerReceiver);
        ClothesHangerOffCommand clothesHangerOffCommand = new ClothesHangerOffCommand(clothesHangerReceiver);

        RemoteController remoteController = new RemoteController();
        // 电灯
        remoteController.setCommand(0, electricLightOnCommand, electricLightOffCommand);
        // 电视
        remoteController.setCommand(1, televisionOnCommand, televisionOffCommand);
        // 冰箱
        remoteController.setCommand(2, refrigeratorOnCommand, refrigeratorOffCommand);
        // 洗衣机
        remoteController.setCommand(3, washingMachineOnCommand, washingMachineOffCommand);
        // 晾衣架
        remoteController.setCommand(4, clothesHangerOnCommand, clothesHangerOffCommand);

        System.out.println("===============================电灯=================================");

        remoteController.onButtonWasPushed(0);
        remoteController.offButtonWasPushed(0);
        remoteController.undoButtonWasPushed();

        System.out.println("================================电视================================");

        remoteController.onButtonWasPushed(1);
        remoteController.offButtonWasPushed(1);
        remoteController.undoButtonWasPushed();

        System.out.println("=================================冰箱===============================");

        remoteController.onButtonWasPushed(2);
        remoteController.offButtonWasPushed(2);
        remoteController.undoButtonWasPushed();

        System.out.println("=================================洗衣机===============================");

        remoteController.onButtonWasPushed(3);
        remoteController.offButtonWasPushed(3);
        remoteController.undoButtonWasPushed();

        System.out.println("=================================晾衣架===============================");

        remoteController.onButtonWasPushed(4);
        remoteController.offButtonWasPushed(4);
        remoteController.undoButtonWasPushed();

        System.out.println("================================================================");
    }
}
